'tgrind' reads the file to be printed and a command line switch to see what the source language is. It then reads a language definition database file and learns the syntax of the language (list of keywords, literal string delimiters, comment delimiters, etc).
'tgrind' usually comes with the public distribution of TeX and LaTeX. Look in the directory:
...tex82/contrib/van/tgrind
A more up-to-date version of tgrind by Jerry Leichter can be found on: